//
//  ZCNavVC.m
//  SSMusic
//
//  Created by 张灿 on 16/4/18.
//  Copyright © 2016年 张灿. All rights reserved.
//

#import "ZCNavVC.h"

@interface ZCNavVC ()

@end

@implementation ZCNavVC



+ (void)initialize
{
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[self class]]];
    //设置背景色RGB(223, 27, 30)
//    bar.barTintColor = [UIColor colorWithRed:223/255.0 green:27/255.0 blue:30/255.0 alpha:1.0];
    bar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cm2_topbar_bg"]];
    
    //设置半透明为NO
    bar.translucent = NO;
    
    //设置显示字体
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];
    dict[NSFontAttributeName] = [UIFont fontWithName:@"HelveticaNeue-Light" size:18.0];
    [bar setTitleTextAttributes:dict];
    
}

//设置全局返回按钮,播放按钮
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //*******************设置全局返回按钮*********************/
    //非根控制器才需要设置
    if (self.childViewControllers.count) {
        //自定义返回按钮
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:@"cm2_topbar_icn_back"] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"cm2_topbar_icn_back_prs"] forState:UIControlStateHighlighted];
        [btn sizeToFit];
        
        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    }
    //*******************设置全局返回按钮*********************/
    
    
    
    //**********设置全局的导航栏右侧音乐按钮****************/
    UIButton *playMusic = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [playMusic setImage:[UIImage imageNamed:@"cm2_topbar_icn_playing"] forState:UIControlStateNormal];
    [playMusic setImage:[UIImage imageNamed:@"cm2_topbar_icn_playing_prs"] forState:UIControlStateHighlighted];
    
    [playMusic sizeToFit];
    
    playMusic.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -10);
    
    [playMusic addTarget:self action:@selector(playMusic) forControlEvents:UIControlEventTouchUpInside];
    
    viewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:playMusic];
    //**********设置全局的导航栏右侧音乐按钮****************/
    
    [super pushViewController:viewController animated:animated];
}
//全局返回按钮
- (void)back
{
    [self popViewControllerAnimated:YES];
}

//全局播放按钮
- (void)playMusic
{
    NSLog(@"播放");
}

/**
 *  设置状态栏显示
 */
-(UIStatusBarStyle)preferredStatusBarStyle{
    
    return UIStatusBarStyleLightContent;
}



@end
